static const char *sdr_src =
	"uniform sampler2D tex;\n"
	"uniform float aspect, scale;\n"
	"uniform float lens_center_offset;\n"
	"uniform vec4 dist_factors;\n"
	"\n"
	"vec2 distort_texcoords(in vec2 tc);\n"
	"float barrel_scale(float x, in vec4 k);\n"
	"\n"
	"void main()\n"
	"{\n"
	"	vec2 tc = distort_texcoords(gl_TexCoord[0].xy);\n"
	"\n"
	"	float vis = any(greaterThan(tc, vec2(1.0)) || lessThan(tc, vec2(0.0))) ? 0.0 : 1.0;\n"
	"\n"
	"	gl_FragColor.rgb = texture2D(tex, tc).rgb * vis;\n"
	"	gl_FragColor.a = 1.0;\n"
	"}\n"
	"\n"
	"vec2 distort_texcoords(in vec2 tc)\n"
	"{\n"
	"	// map tc [0, 1] -> [-1, 1]\n"
	"	vec2 pt = tc * 2.0 - 1.0;\n"
	"\n"
	"	pt.x += lens_center_offset * 2.0;\n"
	"	pt.y /= aspect;	// correct for aspect ratio\n"
	"\n"
	"	float rad = barrel_scale(dot(pt, pt), dist_factors);\n"
	"	pt *= rad;	// scale the point by the computer distortion radius\n"
	"\n"
	"	pt /= scale;\n"
	"	pt.y *= aspect;\n"
	"	pt.x -= lens_center_offset * 2.0;\n"
	"\n"
	"	// map back to range [0, 1]\n"
	"	return pt * 0.5 + 0.5;\n"
	"}\n"
	"\n"
	"float barrel_scale(float rad, in vec4 k)\n"
	"{\n"
	"	float radsq = rad * rad;\n"
	"	float radquad = radsq * radsq;\n"
	"	return k.x + k.y * radsq + k.z * radquad + k.w * radquad * radsq;\n"
	"}\n";

